@extends('layouts.admin')
@section('css')
  <link href="{{ asset('admin/assets/advanced-datatable/media/css/demo_page.css') }}" rel="stylesheet" />
  <link href="{{ asset('admin/assets/advanced-datatable/media/css/demo_table.css') }}" rel="stylesheet">
  <link href="{{ asset('admin/assets/bootstrap-datepicker/css/datepicker.css') }}" rel="stylesheet">
  <link href="{{ asset('admin/assets/bootstrap-daterangepicker/daterangepicker-bs3.css') }}" rel="stylesheet">
@endsection
@section('content')
<section id="main-content">
  <section class="wrapper">
      <!-- page start-->
      <div class="row">
          <div class="col-lg-12">
              <section class="panel">
                  <header class="panel-heading">
                      佣金明细
                  </header>
                  <div class="panel-body right"  align="right">
                              <div class="form-group col-md-2 " align="left" >
                                    <button  class="btn btn-primary settle" name="to" data-href="{{ route('admin.finance.commission.settle') }}">结算</button> 
                                    <button  class="btn btn-danger settleAll" name="to" data-href="{{ route('admin.finance.commission.settle.all') }}">全部结算</button>
                                    <!-- <button  class="btn btn-danger cancel" name="to" data-href="{{ route('admin.finance.commission.cancel') }}">作废</button>  -->
                                  </div>
                             <form class="form-inline col-md-10 " action="{{ route('admin.finance.commission') }}" role="form" method="get">
                                  
                                  
                                  
                                  {{ csrf_field() }}
                                  <div class="form-group">
                                      
                                      <label class="sr-only" for="exampleInputEmail2">选择状态</label>
                                          <select class="form-control" name="status">
                                              <option value="-1" {{ -1==$data['status'] ? 'selected':'' }}>所有</option>
                                              <option value="0" {{ 0==$data['status'] ? 'selected':'' }}>未结算</option>
                                              <option value="1" {{ 1==$data['status'] ? 'selected':'' }}>已结算</option>
                                                                           
                                          </select>
                                      
                                  </div>

                                  <div class="form-group">
                                      <label class="sr-only" for="exampleInputEmail2">用户名</label>
                                      <input type="text" class="form-control tooltips" id="name" data-toggle="tooltip" name="name" value="{{ $data['name'] }}" placeholder="输入分用者用户名">
                                  </div>
                                  <div class="form-group">
                                      <label class="sr-only" for="exampleInputPassword2">电话</label>
                                      <input type="text" class="form-control" id="mobile" name="mobile" value="{{ $data['mobile'] }}" placeholder="输入分用者手机">
                                  </div>

                                  <div class="form-group "  >
                                    
                                              <input type="text" class="form-control dpd1" name="from" value="{{ $data['from'] }}" placeholder="开始日期">
                                              
                                  </div>
                                  -
                                  <div class="form-group "  >
                                      <!-- <label class="control-label col-md-3 sr-only">下单时间</label> -->
                                      <!-- <div class="col-md-4" > -->
                                          <!-- <div class="input-group input-large" data-date="13/07/2013" data-date-format="mm/dd/yyyy"> -->
                                              <!-- <input type="text" class="form-control dpd1" name="from"> -->
                                              <!-- <span class="input-group-addon">To</span> -->
                                              <input type="text" class="form-control dpd2" name="to" value="{{ $data['to'] }}" placeholder="截止日期">
                                          <!-- </div> -->
                                          <!-- <span class="help-block">Select date range</span> -->
                                      <!-- </div> -->
                                  </div>

                                  <button type="submit" class="btn btn-info">搜索</button>
                              </form>

                          </div>
                  <table class="table table-striped table-advance table-hover">
                      <thead>
                      <tr>
                          <th>
                                        <span class="ckbox ckbox-primary">
                                            <input type="checkbox" id="selectall"/>
                                            <label for="selectall"></label>
                                        </span>
                                    </th>
                          <th> ID</th>
                          <th>订单编号</th>
                          <th>下单者</th>
                          <th>分佣单者</th>
                          <th>订单金额</th>
                          <th>分佣金额</th>
                          <th>级数</th>
                          <th>说明</th>
                          <!-- <th>支付金额</th> -->
                          <th><i class=" icon-edit"></i> 状态</th>
                          <th>支付时间</th>
                          <th>创建时间</th>
                          <!-- <th>更新时间</th> -->
                          <!-- <th></th> -->
                      </tr>
                      </thead>
                      <tbody>
                      @foreach($commissions as $commission)
                      <tr>
                          <td>
                              <div class="ckbox ckbox-default">
                                  <input type="checkbox" name="id" id="id-{{ $commission->id }}"
                                         value="{{ $commission->id }}" class="selectall-item"/>
                                  <label for="id-{{ $commission->id }}"></label>
                              </div>
                          </td>
                          <th> {{ $commission->id }}</th>
                          <th> {{ $commission->orderno }}</th>
                          <th> {{ $commission->order_user->mobile }}</th>
                          <th> {{ $commission->commission_user->mobile }}</th>
                          <th >￥{{ $commission->amount }}</th>
                          <th>{{ $commission->commission }}</th>
                          <th>{{ $commission->commission_user_level }}</th>
                          <th>{{ $commission->note }}</th>


                          <th><span class="label {{ $commission->statuslabel() }} label-mini"> {!! $commission->status() !!}</span></th>
                          <th>{{ $commission->created_at }}</th>
                          <th>{{ $commission->updated_at }}</th>
                        
                          <!-- <th>
                           
                              <button class="btn btn-warning btn-xs"><i class="icon-pencil"></i></button>
                              
                          </th> -->

                          
                      </tr>
                      @endforeach

                      </tbody>
                  </table>
                  {!! $commissions->appends($data)->links() !!}
              </section>
          </div>
      </div>
      <!-- page end-->
  </section>
</section>
@endsection
@section('javascript')
<script type="text/javascript" language="javascript" src="{{ asset('admin/assets/advanced-datatable/media/js/jquery.dataTables.js') }}"></script>
<script type="text/javascript" src="{{ asset('admin/assets/bootstrap-datepicker/js/bootstrap-datepicker.js') }}"></script>
<script type="text/javascript" src="{{ asset('admin/assets/bootstrap-daterangepicker/daterangepicker.js') }}"></script>
 <script src="{{ asset('admin/js/advanced-form-components.js') }}"></script>
 <script type="text/javascript" charset="utf-8">
      
        $(".settle").click(function () {
            Rbac.ajax.settleSelect({
                confirmTitle: '确定结算选中的佣金吗?',
                href: $(this).data('href'),
                successTitle: '结算成功'
            });
        });

        $(".settleAll").click(function () {
            Rbac.ajax.settle({
                confirmTitle: '确定结算所有佣金吗?',
                href: $(this).data('href'),
                successTitle: '结算成功'
            });
        });

        $(".cancel").click(function () {
            Rbac.ajax.cancel({
                confirmTitle: '确定作废选中的佣金吗?',
                href: $(this).data('href'),
                successTitle: '作废成功'
            });
        });
    
      
  </script>  
@endsection

